Release 10.1A: OpenEdge Development:
Programming Interfaces
Receiving input from multiple sources
At some points in a procedure you might want to get input from the terminal, but at other points you might want to get input from a file. A single procedure can use multiple input sources.
For example, suppose you want to create records for the customers in the
i-datf1.ddata file. Before creating the records, you probably want to display the customer numbers in the file and ask if the user wants to create customer records for those numbers. To do this, you need input from the terminal. If the user wants to create customer records for the customers in thei-datf1.dfile, you also need input from the file.The
i-chgin2.pprocedure uses multiple input sources to perform the work described above. Becausei-chgin2.puses the same data file (i-datf1.d) you used in the previous section to create customer records, you must delete customers 90, 91, and 92 from your database before you runi-chgin2.p. Use the following procedure to delete the customers:
Figure 5–7 shows the
i-chgin2.pprocedure.Figure 5–7: Multiple input sources
![]()
These are the specific steps the procedure follows:
- The
DISPLAYstatement displays some text.- The first
INPUTFROMstatement redirects the input source to thei-datf1.dfile.- The
SETstatement assigns the values in thei-datf1.dfile to thecust–num–var,name–var, andsales–rep–varvariables. As it assigns the values to these variables, you see the values on the terminal screen.- The
INPUT FROM TERMINALstatement redirects the input source to the terminal. TheINPUT CLOSEstatement could have been used instead of theINPUT FROM TERMINALstatement. However, since this procedure might have been called from another procedure, it is better to be explicit about the input source you want to use.- The
SETanswer statement prompts you to create database records for the customer data just displayed. If you answer yes, the procedure:
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |